package T1;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {


	public static List<String> convertStringToList(String line) {
		Scanner sc=new Scanner(line);
		List<String> word=new ArrayList<String>();
		while(sc.hasNext()){
			word.add(sc.next());
		}
		sc.close();
		return word;
	}

	public static void remove(List<String> list, String str){
		while(list.contains(str)){
		list.remove(str);
		}
	}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            List<String> list = convertStringToList(sc.nextLine());
            System.out.println(list);
            String word = sc.nextLine();
            remove(list,word);
            System.out.println(list);
        }
        sc.close();
    }

}


if(item.equals(null)) return null;
else { 
	list.add(item);
	return item;
}